<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var str = prompt('')
        var value = '123'

        function fn(a, b) {
            // 定义变量接收从字符串str中截取到的最后一段的字符串
            var res = str.substr((str.length - value.length), value.length)

            // 判断从字符串str中截取到的最后一段的字符串是否指定的字符串
            if (res === value) {
                return true
            } else {
                return false
            }
        }

        console.log(fn(str, value))
    </script>
</body>

</html>